package com.aisile.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther:yry
 * @Date:2024/1/12 0012
 * @VERSON:1.0
 */
@Configuration
public class RabbitMQConfigCJ {

    // 交换机  ctrl+shift+u 转换成小写快捷键
    public static final String CJ_EXCHANGE = "cj_exchange";
    // 消息队列
    public static final String cj_QUEUE = "cj_queue";

    @Bean(cj_QUEUE)
    public Queue MESSAGE_QUEUE(){
        return new Queue(cj_QUEUE,true);
    }

    @Bean(CJ_EXCHANGE)
    public DirectExchange CJ_EXCHANGEv(){
        return (DirectExchange)ExchangeBuilder.directExchange(CJ_EXCHANGE).delayed().durable(true).build();
    }

    @Bean
    public Binding DLX_EXCHANGE_MESSAGE_QUEUE(
            @Qualifier(CJ_EXCHANGE) DirectExchange directExchange,
            @Qualifier(cj_QUEUE) Queue queue){
        return BindingBuilder.bind(queue).to(directExchange).with(CJ_EXCHANGE);
    }




}
